//
//  JZCourseCell.m
//  chuanke
//
//  Created by jinzelu on 15/7/23.
//  Copyright (c) 2015年 jinzelu. All rights reserved.
//

#import "JRDCourseCell.h"
//#import "UIImageView+WebCache.h"
#import "JrdCommon.h"
#import "JrdCourseModel.h"
@interface JRDCourseCell (){
    Boolean isShowPer;
    int percent;
}

@end

@implementation JRDCourseCell

-(id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self initViews];
    }
    isShowPer = false;
    percent=0;
    return self;
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

-(void)initViews{
    _imageView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 11, JRD_COURSE_CELL_IMG_W, JRD_COURSE_CELL_IMG_H)];
    [self addSubview:_imageView];
    
    _button = [[UIButton alloc]initWithFrame:CGRectMake((SCREEN_WIDTH - 60), (JRD_COURSE_TABLE_H - 30)/2, 50, 30)];
    [_button setTitle:@"学习" forState:UIControlStateNormal];
    [_button setBackgroundColor:[UIColor redColor]];
    //[self addSubview:_button];
    
    _titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(80, 15, SCREEN_WIDTH -100, 25)];
    _subtitleLabel.font = [UIFont systemFontOfSize:18.f];

    [self addSubview:_titleLabel];

    _subtitleLabel = [[UILabel alloc] initWithFrame:CGRectMake(80, 43, SCREEN_WIDTH-150, 15)];
    _subtitleLabel.font = [UIFont systemFontOfSize:12.f];
    _subtitleLabel.textColor = [UIColor lightGrayColor];
    _subtitleLabel.numberOfLines = 2;
    [self addSubview:_subtitleLabel];
    
    _rightLabel = [[UILabel alloc] initWithFrame:CGRectMake((SCREEN_WIDTH - 80), 0, 50, JRD_COURSE_TABLE_H)];
    _rightLabel.font=[UIFont systemFontOfSize:40.f];
    _rightLabel.textColor = JrdGreenColor;
    _rightLabel.text=@"";
    _rightLabel.textAlignment = NSTextAlignmentRight;
    [self addSubview:_rightLabel];
    
    _rightLabel2 = [[UILabel alloc] initWithFrame:CGRectMake((SCREEN_WIDTH - 27), JRD_COURSE_TABLE_H/2, 27, JRD_COURSE_TABLE_H/4)];
    _rightLabel2.font=[UIFont systemFontOfSize:12.f];
    _rightLabel2.textColor = JrdBlackColor;
    _rightLabel2.text=@"";
    _rightLabel2.textAlignment = NSTextAlignmentLeft;
    [self addSubview:_rightLabel2];

}

-(void)setJzCourseM:(JrdCourseModel *)jzCourseM{
    _jzCourseM = jzCourseM;
    NSString* coursePhoto = [jzCourseM.coursePhoto stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

    [_imageView sd_setImageWithURL:[NSURL URLWithString:coursePhoto] placeholderImage:[UIImage imageNamed:@"lesson_default"]];
    _titleLabel.text = jzCourseM.courseName;
    _subtitleLabel.text = jzCourseM.courseDes;
}


-(void)setPercent:(int)percent{
    isShowPer = true;
    _rightLabel.text=[NSString stringWithFormat:@"%d", percent];
    _rightLabel2.text=@"%";//[NSString stringWithFormat:@"%", percent];
}
@end
